package com.recommend.service.admin.impl;

import java.util.List;

import javax.annotation.Resource;

import org.slf4j.Logger;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.recommend.domain.CommentDomain;
import com.recommend.dto.admin.Comment;
import com.recommend.persistence.CommentDomainMapper;
import com.recommend.service.CommentService;

/**
 * Created by lw.
 */
@Service
@Transactional
public class CommentServiceImpl implements CommentService{
    private final static Logger logger = org.slf4j.LoggerFactory.getLogger(LoginServiceImpl.class);

    @Resource
    private CommentDomainMapper commentDomainMapper;

    @Override
    public List<CommentDomain> getAllCommentGroupByMovie(){
        return commentDomainMapper.selectAllGroupByMovie();
    }

    @Override
    public List<Integer> getAllMovie(){
        return commentDomainMapper.selectAllMovie();
    }

    @Override
    public List<Integer> getMovieSelective(Comment comment){
        return commentDomainMapper.getMovieSelective(comment);
    }

    public List<Integer> getCustomerByMovieSelective(Comment comment){
        return commentDomainMapper.getCustomerSelective(comment);
    }

    @Override
    public List<Integer> getCustomer(int movieId){
        return commentDomainMapper.selectCustomerByMovie(movieId);
    }

    @Override
    public List<Comment> getComment(CommentDomain commentDomain) {
        logger.debug("=============comment service: movieId:{}, customerId: {}", commentDomain.getMovieId(), commentDomain.getCustomerId());
        return commentDomainMapper.selectCommentSelective(commentDomain);
    }

	@Override
	public List<Comment> selectCommentsByMovie(Integer id) {
		return commentDomainMapper.selectCommentByMovie(id);
	}

    @Override
    public void insertComment(CommentDomain commentDomain){
        commentDomainMapper.insertSelective(commentDomain);
    }

    @Override
    public int deleteComment(int commentId){
        return commentDomainMapper.deleteByPrimaryKey(commentId);
    }

}